package com.cskaoyan.main;

import com.cskaoyan.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2022/06/30 11:33
 *
 * @author ciggar
 */
public class StatementDemo {

    public static void main(String[] args) throws SQLException {

        Connection connection = JDBCUtils.getConnection();

        Statement statement = connection.createStatement();

        // 通过execute方法执行SQL语句
        boolean ret = statement.execute("select * from student");

        System.out.println("ret:" + ret);

        ResultSet resultSet = statement.getResultSet();

        resultSet.afterLast();

        while (resultSet.previous()) {
            String name = resultSet.getString("name");

            System.out.println("name:" + name);
        }

    }
}
